package com.example.springbootswagger.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

//@Configuration
//@EnableSwagger2
public class SwaggerConfiguration {

    private static ApiInfo DEFAULT = null;

    //@Bean
    public Docket docket(Environment environment) {
        Contact DEFAULT_CONTACT = new Contact("姜兴", "http://www.baidu.com", "2465180091@qq.com");
        DEFAULT = new ApiInfo(
                "姜兴的开发接口",
                "Api Documentation",
                "V-1.0",
                "http://www.baidu.com",
                DEFAULT_CONTACT,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
        Profiles profiles = Profiles.of("dev");
        boolean b = environment.acceptsProfiles(profiles);
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(DEFAULT).enable(b).select().apis(RequestHandlerSelectors.basePackage("com.example")).build();
    }
}
